//
//  Kanbox_TrendDetailViewController.m
//  fxxiaoke
//
//  Created by 鞠超 on 2016/10/15.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Kanbox_TrendDetailViewController.h"

@interface Kanbox_TrendDetailViewController () <UIScrollViewDelegate>

@property (nonatomic, strong) UIScrollView * scrollView;

@property (nonatomic, strong) NSMutableArray * arr_pic;

@end

@implementation Kanbox_TrendDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.arr_pic = @[@"",@"",@"",@"",@"",@"",@"",@""].mutableCopy;
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = [NSString stringWithFormat:@"1/%ld",self.arr_pic.count];
    _topView.backgroundColor = navi_bar_bg_color;
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 70, 15)];
    lbl_return.text = @"网盘动态";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 90, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //
    UIImageView * image_share = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 35, 32, 20, 20)];
    image_share.image = [UIImage imageNamed:@"Share_ Omit.png"];
    [_topView addSubview:image_share];
    
    UIButton * btn_share = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_share.frame = CGRectMake(SCREEN_WIDTH - 10 - 35, 24.5, 35, 35);
    [_topView addSubview:btn_share];
    [btn_share addTarget:self action:@selector(btn_shareAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

//右设置
- (void )btn_shareAction:(UIButton *)sender
{
    NSLog(@"设置");
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor blackColor];
    
    CGFloat length_x = (SCREEN_HEIGHT - 64) / 9;
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64 + length_x * 2, SCREEN_WIDTH, length_x * 4)];
    self.scrollView.delegate = self;
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH * self.arr_pic.count, 0);
    self.scrollView.backgroundColor = [UIColor blackColor];
    self.scrollView.pagingEnabled = YES;
    [self.view addSubview:self.scrollView];
    
    for (int i = 0; i < self.arr_pic.count; i ++)
    {
        UIImageView * image_pic = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, length_x * 4)];
        image_pic.layer.masksToBounds = YES;
        image_pic.image = [UIImage imageNamed:@"heads.jpg"];
        [self.scrollView addSubview:image_pic];
    }
}

#pragma mark - scrollView代理
- (void )scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    NSInteger length_x = scrollView.contentOffset.x / SCREEN_WIDTH;
    
    _lblTitle.text = [NSString stringWithFormat:@"%ld/%ld",length_x + 1,self.arr_pic.count];
}


#pragma mark - 懒加载
- (NSMutableArray *)arr_pic
{
    if(_arr_pic == nil)
    {
        self.arr_pic = [NSMutableArray array];
    }
    
    return _arr_pic;
}













@end
